[Top] [Prev] [Next] [Bottom] [Contents]

Activators

When working with Sapphire/Web it is important to understand the mark-ups that it makes to your HTML. There are a number of different types of activator in common use; Sapphire/Web allows almost anything to become an activator.

Some activator types that you commonly encounter include:

The two most common activators are HTML Anchors and Forms.

HTML Activators

We start with a pure piece of HTML:

<html>
<head><title></title></head>
<body>
Please press me here to get an author list
</body>
</html>
where we have just one single line of text. To create an Anchor on this page, alter the text line to read

Please press me <A HREF="AnchorName">here</A> to get an 
author list
Within Sapphire/Web, with this HTML document loaded, you will see that Sapphire/Web offers you an anchor to bind to. After a typical binding, the line in the HTML file (which is re-written by Sapphire/Web) might well look something like this:

Please press me <A 
HREF="http://heartofgold/scripts/popcall.exe?FNC=autho
rs__Asamp_html">Title</A> 
to get an author list. The HREF has been changed to call your server application with an argument. Now lets look at the change made to the HREF.

Universal Resource Locator

The first part of the HREF ("http://heartofgold/scripts/popcall.exe"), up to the "?", is the Universal Resource Locator (URL) of your server application. The pathname is from the "Test.CGI URL" option (see the Options Editor in the chapter on the User Interface) for the project with the server application's executable name appended. In this case, looking in the Test tab, you would see the CGI URL defined as http://heartofgold/scripts.

Argument

The part after the "?" ("FNC=authors__Asamp_html") will be either argv[1] (the first argument supplied to it, if it accepts arguments like that) to your server application, or the contents of the "QUERY STRING" environment variable.

You can use the argv[1] approach for debugging. In the above example, type this at the prompt of a command-line window:

<ProgramName> FNC=authors__Asamp_html
The server application will print to standard out (normally the screen) what it would have sent back to the HTML browser.

The HTTP server will most likely also set the "QUERY_STRING" environment variable. Whether it does or not, the server application will read the part after "FNC=" to obtain the string name that is used to look up the "Activator" function for that bound Anchor.

The Function Name, "Aauthors" is a static function written in the HTML-related module. This is the name of the Anchor with "A" prepended.

The string name "authors__Asamp_html" is used as a look-up to invoke the function Aauthors. This string name is derived from the anchor name and the modified HTML filename with "__A" inserted between.

The registration of that lookup string is in the registration function for that HTML-related module. The registration function is not static; it is called from the main() of the program, and would have the name R_samp_html in this case. This name is derived from the modified HTML filename with "R_" prepended.

Form Activators

There are two different types of Form Activator - Post and Get - available for use. Some browsers do not support the Get technique and Post is strongly recommended as the preferred technique.

Post

To activate a form, use the following HTML fragment:

<FORM ACTION="AuthorForm" METHOD="post"> 
</FORM> 
Of course this form is a little boring since it has no input elements. The ACTION string, "AuthorForm", will be seen as the form name in the activator selector. After this is bound as an activator, the fragment will look like:

<FORM ACTION="http://heartofgold/scripts/example.exe" 
METHOD="post"> 
<INPUT TYPE="hidden" NAME="SaFormName" 
VALUE="GroupBy__Fst_html"> 
</FORM>
Sapphire/Web has changed the action value to the URL of the server application and added a hidden element. This element has the name "SaFormName" and the value "GroupBy__Fst_html". The element name is used by Sapphire/Web server applications to look up the value "GroupBy__Fst_html".

The look up, registration, and dispatching are exactly the same as for Anchors, except that instead of "__A" sandwiched in the middle to derive the lookup string, "__F" is used.

Therefore within in the same HTML file the anchor names must be unique and the form names must be unique. However, a form and an anchor could share the same name within the same HTML file.

For forms you get arguments from Input Elements. For example:

<FORM ACTION="TwoArgs" METHOD="post" >
<INPUT NAME="LastName" VALUE="" >
<INPUT NAME="FirstName" VALUE="" >
<INPUT TYPE="submit" NAME="SubmitName" VALUE="Insert">
</FORM>
In the contrib/html and config/htmlstyles directories of Sapphire/Web there are a number of files with different kinds of HTML fragments. These files will show different form element constructs and other HTML pieces.

Get

The method parameter GET is not supported for form elements, so browsers which do not support the POST method (like Mosaic 2.4) cannot be used. There are no plans to support this in the future for two reasons.

Adding New Activator Types

Sapphire/Web is designed to allow the application developer to bind to HTML Forms and Anchors as activators. However in HTML, there are more activator types (types that call server applications) than these, and not all Web files are in HTML.

Further complicating matters is the fact that the Web languages are evolving rapidly. To support arbitrary activator types, Sapphire/Web allows you to add your own keywords. These will then become bindable activators. To add new keywords to Sapphire/Web, just add them to the file:

config/SaKeyWds.ini
in the Sapphire/Web installation. The Sapphire/Web installation may not contain this file unless you create it. Sapphire looks for the file at start-up and bypasses it if it is not present. Therefore, if you create or change the file, you will have to re-start Sapphire/Web for it to be read.

Adding Frames - keyword "SRC"

Netscape supports frames. The contents of a frame are obtained from a URL. The keyword for this is:

SRC="urlpath"
For example,

src="http://example/topofpage.html"
If you define SRC as a Sapphire/Web keyword in SaKeyWds.Ini, you should then be able to see the various invocations for defining what is to go into each frame. You can thus arrange for the contents of a frame to be defined at runtime. For an example, see the logging example in the help file on State.

In brief, the frameset definition looks like this:

	<FRAMESET rows="20%,*">
		<FRAME src="topframeURL" name="topframe">
		<FRAME src="bottomframeURL" name="bottomframe"> 
	</FRAMESET>
You can see that the definitions of the sources - normally URLs - are just symbolic names - "topframeURL" and "bottomframeURL". When the HTML file with this frameset is loaded into Sapphire/Web you can see these as activators and give them definitions. For example, you might have a database of different URL names and use a query to obtain one of these strings to place into the frameset at runtime.

You must remember to define SRC in capitals, not lower-case letters. Sapphire/Web has a strict code for usage of activators and the case in which they are defined (see below). If you try using "src" instead of "SRC" then you'll see nothing.

Adding Maps - keyword "HREF"

HTML also has the MAP tag for image maps. An example of a MAP tag is:

<MAP NAME="mainmap">
<AREA COORDS="0,0,78,24" HREF="/news/index.html">
<AREA COORDS="79,0,156,24" HREF="/weather/index.html">
<AREA COORDS="157,0,234,24" 
HREF="/employment/index.html">
<AREA COORDS="235,0,312,24" TARGET="_top" 
HREF="/index.html">
<AREA COORDS="313,0,390,24" HREF="/help/index.html" 
TARGET="_top">
<AREA COORDS="391,0,467,24" HREF="/more/index.html">
</MAP>
The keyword for the different area is:

HREF="urlpath"

Adding VRML - keyword "name|"

VRML supports the use of two in-line activators, WWWInline, and anchors, WWWAnchor. An example of this syntax is:

DEF SUN WWWAnchor {
		name "http://www.w3.org/" # The WWW root URL
		description "A link from the Sun to W3.ORG" # 
Decriptive text
		# Inside the anchor, because WWWAnchor is a 
group node
		# We reference using the WWWInline node
		WWWInline {
			name "/anothersun.wrl"
			bboxSize 10 10 10
			bboxCenter 0 0 0
					}
				}
The keyword usage in both of these cases is:

name "urlpath"

Adding More New Activators

To bind to all these activators add the following keywords to the SaKeyWds.ini file:

SRC

This keyword allows you to bind to any set of characters of the form:

<SRC (case insensitive)><any amount of white spaces><an 
equals sign><a URL in quotes>
Of course you will also pick up activators of the form:

<IMG SRC="http://www.bluestone.com/gizmos/ThisPic.gif">

HREF

This keyword allows you to bind to any set of characters of the form:

<HREF (case insensitive)><any amount of white space><an 
equals sign ><a URL in quotes>
The HREF is also used in the standard anchor, but Sapphire distinguishes between the two.

name|

This keyword (notice the pipe character at the end) allows you to bind to any set of characters of the form:

<name (case insensitive)><a space character><any amount 
of white space><a URL in quotes>
The WWWInline will require VRML text as the return so you will need to change the default content string (see SaPopulateForText in the Reference Manual).

General Syntax

There are a few simple rules. Although they are simple, enforcement is strict: a mistake in case, for example, can render all tags of a certain category invisible and unrecognized!

<param name="ParameterName" value=" saact='value' "
In this case, saact itself has a value, which must be denoted by "single ticks" or "primes" because it lies within quotes.



[Top] [Prev] [Next] [Bottom] [Contents]

info@bluestone.com
Copyright © 1997, Bluestone. All rights reserved.